userstyle should be last in css import list
[lhc/web/wiklou.git] / includes / Skin.php
1 <?php
2
3 /**
4 *
5 * @package MediaWiki
6 * @subpackage Skins
7 */
8
9 /**
10 * This is not a valid entry point, perform no further processing unless MEDIAWIKI is defined
11 */
12 if( defined( "MEDIAWIKI" ) ) {
13
14 # See skin.txt
15 require_once( 'Linker.php' );
16 require_once( 'Image.php' );
17
18 # Get a list of all skins available in /skins/
19 # Build using the regular expression '^(.*).php$'
20 # Array keys are all lower case, array value keep the case used by filename
21 #
22
23 $skinDir = dir($IP.'/skins');
24
25 # while code from www.php.net
26 while (false !== ($file = $skinDir->read())) {
27 if(preg_match('/^([^.].*)\.php$/',$file, $matches)) {
28 $aSkin = $matches[1];
29 $wgValidSkinNames[strtolower($aSkin)] = $aSkin;
30 }
31 }
32 $skinDir->close();
33 unset($matches);
34
35 require_once( 'RecentChange.php' );
36
37 /**
38 * @todo document
39 * @package MediaWiki
40 */
41 class RCCacheEntry extends RecentChange
42 {
43 var $secureName, $link;
44 var $curlink , $difflink, $lastlink , $usertalklink , $versionlink ;
45 var $userlink, $timestamp, $watched;
46
47 function newFromParent( $rc )
48 {
49 $rc2 = new RCCacheEntry;
50 $rc2->mAttribs = $rc->mAttribs;
51 $rc2->mExtra = $rc->mExtra;
52 return $rc2;
53 }
54 } ;
55
56
57 /**
58 * The main skin class that provide methods and properties for all other skins
59 * including PHPTal skins.
60 * This base class is also the "Standard" skin.
61 * @package MediaWiki
62 */
63 class Skin extends Linker {
64 /**#@+
65 * @access private
66 */
67 var $lastdate, $lastline;
68 var $rc_cache ; # Cache for Enhanced Recent Changes
69 var $rcCacheIndex ; # Recent Changes Cache Counter for visibility toggle
70 var $rcMoveIndex;
71 /**#@-*/
72
73 /** Constructor, call parent constructor */
74 function Skin() { parent::Linker(); }
75
76 function getSkinNames() {
77 global $wgValidSkinNames;
78 return $wgValidSkinNames;
79 }
80
81 /** @return string path to the skin stylesheet */
82 function getStylesheet() { return 'common/wikistandard.css'; }
83
84 /** @return string skin name */
85 function getSkinName() {
86 return 'standard';
87 }
88
89 function qbSetting() {
90 global $wgOut, $wgUser;
91
92 if ( $wgOut->isQuickbarSuppressed() ) { return 0; }
93 $q = $wgUser->getOption( 'quickbar' );
94 if ( '' == $q ) { $q = 0; }
95 return $q;
96 }
97
98 function initPage( &$out ) {
99 $fname = 'Skin::initPage';
100 wfProfileIn( $fname );
101
102 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => '/favicon.ico' ) );
103
104 $this->addMetadataLinks($out);
105
106 wfProfileOut( $fname );
107 }
108
109 function addMetadataLinks( &$out ) {
110 global $wgTitle, $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf, $wgRdfMimeType, $action;
111 global $wgRightsPage, $wgRightsUrl, $wgUseTrackbacks;
112
113 if( $out->isArticleRelated() ) {
114 # note: buggy CC software only reads first "meta" link
115 if( $wgEnableCreativeCommonsRdf ) {
116 $out->addMetadataLink( array(
117 'title' => 'Creative Commons',
118 'type' => 'application/rdf+xml',
119 'href' => $wgTitle->getLocalURL( 'action=creativecommons') ) );
120 }
121 if( $wgEnableDublinCoreRdf ) {
122 $out->addMetadataLink( array(
123 'title' => 'Dublin Core',
124 'type' => 'application/rdf+xml',
125 'href' => $wgTitle->getLocalURL( 'action=dublincore' ) ) );
126 }
127 }
128 $copyright = '';
129 if( $wgRightsPage ) {
130 $copy = Title::newFromText( $wgRightsPage );
131 if( $copy ) {
132 $copyright = $copy->getLocalURL();
133 }
134 }
135 if( !$copyright && $wgRightsUrl ) {
136 $copyright = $wgRightsUrl;
137 }
138 if( $copyright ) {
139 $out->addLink( array(
140 'rel' => 'copyright',
141 'href' => $copyright ) );
142 }
143 }
144
145 function outputPage( &$out ) {
146 global $wgDebugComments;
147
148 wfProfileIn( 'Skin::outputPage' );
149 $this->initPage( $out );
150
151 $out->out( $out->headElement() );
152
153 $out->out( "\n<body" );
154 $ops = $this->getBodyOptions();
155 foreach ( $ops as $name => $val ) {
156 $out->out( " $name='$val'" );
157 }
158 $out->out( ">\n" );
159 if ( $wgDebugComments ) {
160 $out->out( "<!-- Wiki debugging output:\n" .
161 $out->mDebugtext . "-->\n" );
162 }
163
164 $out->out( $this->beforeContent() );
165
166 $out->out( $out->mBodytext . "\n" );
167
168 $out->out( $this->afterContent() );
169
170 wfProfileClose();
171 $out->out( $out->reportTime() );
172
173 $out->out( "\n</body></html>" );
174 }
175
176 function getHeadScripts() {
177 global $wgStylePath, $wgUser, $wgContLang, $wgAllowUserJs, $wgJsMimeType;
178 $r = "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js\"></script>\n";
179 if( $wgAllowUserJs && $wgUser->isLoggedIn() ) {
180 $userpage = $wgUser->getUserPage();
181 $userjs = htmlspecialchars( $this->makeUrl(
182 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
183 'action=raw&ctype='.$wgJsMimeType));
184 $r .= '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>\n";
185 }
186 return $r;
187 }
188
189 /**
190 * To make it harder for someone to slip a user a fake
191 * user-JavaScript or user-CSS preview, a random token
192 * is associated with the login session. If it's not
193 * passed back with the preview request, we won't render
194 * the code.
195 *
196 * @param string $action
197 * @return bool
198 * @access private
199 */
200 function userCanPreview( $action ) {
201 global $wgTitle, $wgRequest, $wgUser;
202
203 if( $action != 'submit' )
204 return false;
205 if( !$wgRequest->wasPosted() )
206 return false;
207 if( !$wgTitle->userCanEditCssJsSubpage() )
208 return false;
209 return $wgUser->matchEditToken(
210 $wgRequest->getVal( 'wpEditToken' ) );
211 }
212
213 # get the user/site-specific stylesheet, SkinPHPTal called from RawPage.php (settings are cached that way)
214 function getUserStylesheet() {
215 global $wgOut, $wgStylePath, $wgRequest, $wgContLang, $wgSquidMaxage;
216 $sheet = $this->getStylesheet();
217 $action = $wgRequest->getText('action');
218 $s = "@import \"$wgStylePath/$sheet\";\n";
219 if($wgContLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css\";\n";
220
221 $query = "action=raw&ctype=text/css&smaxage=$wgSquidMaxage";
222 $s .= '@import "' . $this->makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI ) . "\";\n" .
223 '@import "'.$this->makeNSUrl( ucfirst( $this->getSkinName() . '.css' ), $query, NS_MEDIAWIKI ) . "\";\n";
224
225 $s .= $this->doGetUserStyles();
226 return $s."\n";
227 }
228
229 /**
230 * placeholder, returns generated js in monobook
231 */
232 function getUserJs() { return; }
233
234 /**
235 * Return html code that include User stylesheets
236 */
237 function getUserStyles() {
238 global $wgOut, $wgStylePath, $wgLang;
239 $s = "<style type='text/css'>\n";
240 $s .= "/*/*/ /*<![CDATA[*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
241 $s .= $this->getUserStylesheet();
242 $s .= "/*]]>*/ /* */\n";
243 $s .= "</style>\n";
244 return $s;
245 }
246
247 /**
248 * Some styles that are set by user through the user settings interface.
249 */
250 function doGetUserStyles() {
251 global $wgUser, $wgContLang, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss;
252
253 $s = '';
254
255 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) { # logged in
256 if($wgTitle->isCssSubpage() && $this->userCanPreview( $action ) ) {
257 $s .= $wgRequest->getText('wpTextbox1');
258 } else {
259 $userpage = $wgUser->getUserPage();
260 $s.= '@import "'.$this->makeUrl(
261 $userpage->getPrefixedText().'/'.$this->getSkinName().'.css',
262 'action=raw&ctype=text/css').'";'."\n";
263 }
264 }
265
266 return $s . $this->reallyDoGetUserStyles();
267 }
268
269 function reallyDoGetUserStyles() {
270 global $wgUser;
271 $s = '';
272 if (($undopt = $wgUser->getOption("underline")) != 2) {
273 $underline = $undopt ? 'underline' : 'none';
274 $s .= "a { text-decoration: $underline; }\n";
275 }
276 if( $wgUser->getOption( 'highlightbroken' ) ) {
277 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
278 } else {
279 $s .= <<<END
280 a.new, #quickbar a.new,
281 a.stub, #quickbar a.stub {
282 color: inherit;
283 text-decoration: inherit;
284 }
285 a.new:after, #quickbar a.new:after {
286 content: "?";
287 color: #CC2200;
288 text-decoration: $underline;
289 }
290 a.stub:after, #quickbar a.stub:after {
291 content: "!";
292 color: #772233;
293 text-decoration: $underline;
294 }
295 END;
296 }
297 if( $wgUser->getOption( 'justify' ) ) {
298 $s .= "#article, #bodyContent { text-align: justify; }\n";
299 }
300 if( !$wgUser->getOption( 'showtoc' ) ) {
301 $s .= "#toc { display: none; }\n";
302 }
303 if( !$wgUser->getOption( 'editsection' ) ) {
304 $s .= ".editsection { display: none; }\n";
305 }
306 return $s;
307 }
308
309 function getBodyOptions() {
310 global $wgUser, $wgTitle, $wgNamespaceBackgrounds, $wgOut, $wgRequest;
311
312 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
313
314 if ( 0 != $wgTitle->getNamespace() ) {
315 $a = array( 'bgcolor' => '#ffffec' );
316 }
317 else $a = array( 'bgcolor' => '#FFFFFF' );
318 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
319 $wgTitle->userCanEdit() ) {
320 $t = wfMsg( 'editthispage' );
321 $oid = $red = '';
322 if ( !empty($redirect) && $redirect == 'no' ) {
323 $red = "&redirect={$redirect}";
324 }
325 if ( !empty($oldid) && ! isset( $diff ) ) {
326 $oid = "&oldid=" . intval( $oldid );
327 }
328 $s = $wgTitle->getFullURL( "action=edit{$oid}{$red}" );
329 $s = 'document.location = "' .$s .'";';
330 $a += array ('ondblclick' => $s);
331
332 }
333 $a['onload'] = $wgOut->getOnloadHandler();
334 if( $wgUser->getOption( 'editsectiononrightclick' ) ) {
335 if( $a['onload'] != '' ) {
336 $a['onload'] .= ';';
337 }
338 $a['onload'] .= 'setupRightClickEdit()';
339 }
340 return $a;
341 }
342
343 /**
344 * URL to the logo
345 */
346 function getLogo() {
347 global $wgLogo;
348 return $wgLogo;
349 }
350
351 /**
352 * This will be called immediately after the <body> tag. Split into
353 * two functions to make it easier to subclass.
354 */
355 function beforeContent() {
356 return $this->doBeforeContent();
357 }
358
359 function doBeforeContent() {
360 global $wgOut, $wgTitle, $wgContLang;
361 $fname = 'Skin::doBeforeContent';
362 wfProfileIn( $fname );
363
364 $s = '';
365 $qb = $this->qbSetting();
366
367 if( $langlinks = $this->otherLanguages() ) {
368 $rows = 2;
369 $borderhack = '';
370 } else {
371 $rows = 1;
372 $langlinks = false;
373 $borderhack = 'class="top"';
374 }
375
376 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
377 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
378
379 $shove = ($qb != 0);
380 $left = ($qb == 1 || $qb == 3);
381 if($wgContLang->isRTL()) $left = !$left;
382
383 if ( !$shove ) {
384 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
385 $this->logoText() . '</td>';
386 } elseif( $left ) {
387 $s .= $this->getQuickbarCompensator( $rows );
388 }
389 $l = $wgContLang->isRTL() ? 'right' : 'left';
390 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
391
392 $s .= $this->topLinks() ;
393 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
394
395 $r = $wgContLang->isRTL() ? "left" : "right";
396 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
397 $s .= $this->nameAndLogin();
398 $s .= "\n<br />" . $this->searchForm() . "</td>";
399
400 if ( $langlinks ) {
401 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
402 }
403
404 if ( $shove && !$left ) { # Right
405 $s .= $this->getQuickbarCompensator( $rows );
406 }
407 $s .= "</tr>\n</table>\n</div>\n";
408 $s .= "\n<div id='article'>\n";
409
410 $notice = wfGetSiteNotice();
411 if( $notice ) {
412 $s .= "\n<div id='siteNotice'>$notice</div>\n";
413 }
414 $s .= $this->pageTitle();
415 $s .= $this->pageSubtitle() ;
416 $s .= $this->getCategories();
417 wfProfileOut( $fname );
418 return $s;
419 }
420
421
422 function getCategoryLinks () {
423 global $wgOut, $wgTitle, $wgParser;
424 global $wgUseCategoryMagic, $wgUseCategoryBrowser, $wgLang;
425
426 if( !$wgUseCategoryMagic ) return '' ;
427 if( count( $wgOut->mCategoryLinks ) == 0 ) return '';
428
429 # Taken out so that they will be displayed in previews -- TS
430 #if( !$wgOut->isArticle() ) return '';
431
432 $t = implode ( ' | ' , $wgOut->mCategoryLinks );
433 $msg = count( $wgOut->mCategoryLinks ) === 1 ? 'categories1' : 'categories';
434 $s = $this->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, 'Categories' ),
435 wfMsg( $msg ), 'article=' . urlencode( $wgTitle->getPrefixedDBkey() ) )
436 . ': ' . $t;
437
438 # optional 'dmoz-like' category browser. Will be shown under the list
439 # of categories an article belong to
440 if($wgUseCategoryBrowser) {
441 $s .= '<br /><hr />';
442
443 # get a big array of the parents tree
444 $parenttree = $wgTitle->getParentCategoryTree();
445 # Skin object passed by reference cause it can not be
446 # accessed under the method subfunction drawCategoryBrowser
447 $tempout = explode("\n", Skin::drawCategoryBrowser($parenttree, $this) );
448 # Clean out bogus first entry and sort them
449 unset($tempout[0]);
450 asort($tempout);
451 # Output one per line
452 $s .= implode("<br />\n", $tempout);
453 }
454
455 return $s;
456 }
457
458 /** Render the array as a serie of links.
459 * @param array $tree Categories tree returned by Title::getParentCategoryTree
460 * @param object &skin Skin passed by reference
461 * @return string separated by &gt;, terminate with "\n"
462 */
463 function drawCategoryBrowser($tree, &$skin) {
464 $return = '';
465 foreach ($tree as $element => $parent) {
466 if (empty($parent)) {
467 # element start a new list
468 $return .= "\n";
469 } else {
470 # grab the others elements
471 $return .= Skin::drawCategoryBrowser($parent, $skin) . ' &gt; ';
472 }
473 # add our current element to the list
474 $eltitle = Title::NewFromText($element);
475 $return .= $skin->makeLinkObj( $eltitle, $eltitle->getText() ) ;
476 }
477 return $return;
478 }
479
480 function getCategories() {
481 $catlinks=$this->getCategoryLinks();
482 if(!empty($catlinks)) {
483 return "<p class='catlinks'>{$catlinks}</p>";
484 }
485 }
486
487 function getQuickbarCompensator( $rows = 1 ) {
488 return "<td width='152' rowspan='{$rows}'>&nbsp;</td>";
489 }
490
491 /**
492 * This gets called immediately before the </body> tag.
493 * @return string HTML to be put after </body> ???
494 */
495 function afterContent() {
496 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
497 return $printfooter . $this->doAfterContent();
498 }
499
500 /** @return string Retrievied from HTML text */
501 function printSource() {
502 global $wgTitle;
503 $url = htmlspecialchars( $wgTitle->getFullURL() );
504 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
505 }
506
507 function printFooter() {
508 return "<p>" . $this->printSource() .
509 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
510 }
511
512 /** overloaded by derived classes */
513 function doAfterContent() { }
514
515 function pageTitleLinks() {
516 global $wgOut, $wgTitle, $wgUser, $wgContLang, $wgRequest;
517
518 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
519 $action = $wgRequest->getText( 'action' );
520
521 $s = $this->printableLink();
522 $disclaimer = $this->disclaimerLink(); # may be empty
523 if( $disclaimer ) {
524 $s .= ' | ' . $disclaimer;
525 }
526
527 if ( $wgOut->isArticleRelated() ) {
528 if ( $wgTitle->getNamespace() == NS_IMAGE ) {
529 $name = $wgTitle->getDBkey();
530 $image = new Image( $wgTitle );
531 if( $image->exists() ) {
532 $link = htmlspecialchars( $image->getURL() );
533 $style = $this->getInternalLinkAttributes( $link, $name );
534 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
535 }
536 }
537 }
538 if ( 'history' == $action || isset( $diff ) || isset( $oldid ) ) {
539 $s .= ' | ' . $this->makeKnownLinkObj( $wgTitle,
540 wfMsg( 'currentrev' ) );
541 }
542
543 if ( $wgUser->getNewtalk() ) {
544 # do not show "You have new messages" text when we are viewing our
545 # own talk page
546
547 if( !$wgTitle->equals( $wgUser->getTalkPage() ) ) {
548 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
549 wfMsg('newmessageslink') );
550 $s.= ' | <strong>'. wfMsg( 'newmessages', $tl ) . '</strong>';
551 # disable caching
552 $wgOut->setSquidMaxage(0);
553 $wgOut->enableClientCache(false);
554 }
555 }
556
557 $undelete = $this->getUndeleteLink();
558 if( !empty( $undelete ) ) {
559 $s .= ' | '.$undelete;
560 }
561 return $s;
562 }
563
564 function getUndeleteLink() {
565 global $wgUser, $wgTitle, $wgContLang, $action;
566 if( (($wgTitle->getArticleId() == 0) || ($action == "history")) &&
567 ($n = $wgTitle->isDeleted() ) )
568 {
569 if ( $wgUser->isAllowed( 'delete' ) ) {
570 $msg = 'thisisdeleted';
571 } else {
572 $msg = 'viewdeleted';
573 }
574 return wfMsg( $msg,
575 $this->makeKnownLink(
576 $wgContLang->SpecialPage( 'Undelete/' . $wgTitle->getPrefixedDBkey() ),
577 wfMsg( 'restorelink' . ($n == 1 ? '1' : ''), $n ) ) );
578 }
579 return '';
580 }
581
582 function printableLink() {
583 global $wgOut, $wgFeedClasses, $wgRequest;
584
585 $baseurl = $_SERVER['REQUEST_URI'];
586 if( strpos( '?', $baseurl ) == false ) {
587 $baseurl .= '?';
588 } else {
589 $baseurl .= '&';
590 }
591 $baseurl = htmlspecialchars( $baseurl );
592 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
593
594 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
595 if( $wgOut->isSyndicated() ) {
596 foreach( $wgFeedClasses as $format => $class ) {
597 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
598 $s .= " | <a href=\"$feedurl\">{$format}</a>";
599 }
600 }
601 return $s;
602 }
603
604 function pageTitle() {
605 global $wgOut, $wgTitle, $wgUser;
606
607 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
608 return $s;
609 }
610
611 function pageSubtitle() {
612 global $wgOut;
613
614 $sub = $wgOut->getSubtitle();
615 if ( '' == $sub ) {
616 global $wgExtraSubtitle;
617 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
618 }
619 $subpages = $this->subPageSubtitle();
620 $sub .= !empty($subpages)?"</p><p class='subpages'>$subpages":'';
621 $s = "<p class='subtitle'>{$sub}</p>\n";
622 return $s;
623 }
624
625 function subPageSubtitle() {
626 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
627 $subpages = '';
628 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
629 $ptext=$wgTitle->getPrefixedText();
630 if(preg_match('/\//',$ptext)) {
631 $links = explode('/',$ptext);
632 $c = 0;
633 $growinglink = '';
634 foreach($links as $link) {
635 $c++;
636 if ($c<count($links)) {
637 $growinglink .= $link;
638 $getlink = $this->makeLink( $growinglink, $link );
639 if(preg_match('/class="new"/i',$getlink)) { break; } # this is a hack, but it saves time
640 if ($c>1) {
641 $subpages .= ' | ';
642 } else {
643 $subpages .= '&lt; ';
644 }
645 $subpages .= $getlink;
646 $growinglink .= '/';
647 }
648 }
649 }
650 }
651 return $subpages;
652 }
653
654 function nameAndLogin() {
655 global $wgUser, $wgTitle, $wgLang, $wgContLang, $wgShowIPinHeader;
656
657 $li = $wgContLang->specialPage( 'Userlogin' );
658 $lo = $wgContLang->specialPage( 'Userlogout' );
659
660 $s = '';
661 if ( $wgUser->isAnon() ) {
662 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get('session.name')] ) ) {
663 $n = wfGetIP();
664
665 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
666 $wgLang->getNsText( NS_TALK ) );
667
668 $s .= $n . ' ('.$tl.')';
669 } else {
670 $s .= wfMsg('notloggedin');
671 }
672
673 $rt = $wgTitle->getPrefixedURL();
674 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
675 $q = '';
676 } else { $q = "returnto={$rt}"; }
677
678 $s .= "\n<br />" . $this->makeKnownLinkObj(
679 Title::makeTitle( NS_SPECIAL, 'Userlogin' ),
680 wfMsg( 'login' ), $q );
681 } else {
682 $n = $wgUser->getName();
683 $rt = $wgTitle->getPrefixedURL();
684 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
685 $wgLang->getNsText( NS_TALK ) );
686
687 $tl = " ({$tl})";
688
689 $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(),
690 $n ) . "{$tl}<br />" .
691 $this->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, 'Userlogout' ), wfMsg( 'logout' ),
692 "returnto={$rt}" ) . ' | ' .
693 $this->specialLink( 'preferences' );
694 }
695 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
696 wfMsg( 'help' ) );
697
698 return $s;
699 }
700
701 function getSearchLink() {
702 $searchPage =& Title::makeTitle( NS_SPECIAL, 'Search' );
703 return $searchPage->getLocalURL();
704 }
705
706 function escapeSearchLink() {
707 return htmlspecialchars( $this->getSearchLink() );
708 }
709
710 function searchForm() {
711 global $wgRequest;
712 $search = $wgRequest->getText( 'search' );
713
714 $s = '<form name="search" class="inline" method="post" action="'
715 . $this->escapeSearchLink() . "\">\n"
716 . '<input type="text" name="search" size="19" value="'
717 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
718 . '<input type="submit" name="go" value="' . wfMsg ('go') . '" />&nbsp;'
719 . '<input type="submit" name="fulltext" value="' . wfMsg ('search') . "\" />\n</form>";
720
721 return $s;
722 }
723
724 function topLinks() {
725 global $wgOut;
726 $sep = " |\n";
727
728 $s = $this->mainPageLink() . $sep
729 . $this->specialLink( 'recentchanges' );
730
731 if ( $wgOut->isArticleRelated() ) {
732 $s .= $sep . $this->editThisPage()
733 . $sep . $this->historyLink();
734 }
735 # Many people don't like this dropdown box
736 #$s .= $sep . $this->specialPagesList();
737
738 /* show links to different language variants */
739 global $wgDisableLangConversion, $wgContLang, $wgTitle;
740 $variants = $wgContLang->getVariants();
741 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
742 foreach( $variants as $code ) {
743 $varname = $wgContLang->getVariantname( $code );
744 if( $varname == 'disable' )
745 continue;
746 $s .= ' | <a href="' . $wgTitle->getLocalUrl( 'variant=' . $code ) . '">' . $varname . '</a>';
747 }
748 }
749
750 return $s;
751 }
752
753 function bottomLinks() {
754 global $wgOut, $wgUser, $wgTitle, $wgUseTrackbacks;
755 $sep = " |\n";
756
757 $s = '';
758 if ( $wgOut->isArticleRelated() ) {
759 $s .= '<strong>' . $this->editThisPage() . '</strong>';
760 if ( $wgUser->isLoggedIn() ) {
761 $s .= $sep . $this->watchThisPage();
762 }
763 $s .= $sep . $this->talkLink()
764 . $sep . $this->historyLink()
765 . $sep . $this->whatLinksHere()
766 . $sep . $this->watchPageLinksLink();
767
768 if ($wgUseTrackbacks)
769 $s .= $sep . $this->trackbackLink();
770
771 if ( $wgTitle->getNamespace() == NS_USER
772 || $wgTitle->getNamespace() == NS_USER_TALK )
773
774 {
775 $id=User::idFromName($wgTitle->getText());
776 $ip=User::isIP($wgTitle->getText());
777
778 if($id || $ip) { # both anons and non-anons have contri list
779 $s .= $sep . $this->userContribsLink();
780 }
781 if( $this->showEmailUser( $id ) ) {
782 $s .= $sep . $this->emailUserLink();
783 }
784 }
785 if ( $wgTitle->getArticleId() ) {
786 $s .= "\n<br />";
787 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
788 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
789 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
790 }
791 $s .= "<br />\n" . $this->otherLanguages();
792 }
793 return $s;
794 }
795
796 function pageStats() {
797 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
798 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
799
800 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
801 if ( ! $wgOut->isArticle() ) { return ''; }
802 if ( isset( $oldid ) || isset( $diff ) ) { return ''; }
803 if ( 0 == $wgArticle->getID() ) { return ''; }
804
805 $s = '';
806 if ( !$wgDisableCounters ) {
807 $count = $wgLang->formatNum( $wgArticle->getCount() );
808 if ( $count ) {
809 $s = wfMsg( 'viewcount', $count );
810 }
811 }
812
813 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
814 require_once('Credits.php');
815 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
816 } else {
817 $s .= $this->lastModified();
818 }
819
820 if ($wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
821 $dbr =& wfGetDB( DB_SLAVE );
822 extract( $dbr->tableNames( 'watchlist' ) );
823 $sql = "SELECT COUNT(*) AS n FROM $watchlist
824 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBKey()) .
825 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
826 $res = $dbr->query( $sql, 'Skin::pageStats');
827 $x = $dbr->fetchObject( $res );
828 $s .= ' ' . wfMsg('number_of_watching_users_pageview', $x->n );
829 }
830
831 return $s . ' ' . $this->getCopyright();
832 }
833
834 function getCopyright() {
835 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
836
837
838 $oldid = $wgRequest->getVal( 'oldid' );
839 $diff = $wgRequest->getVal( 'diff' );
840
841 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
842 $msg = 'history_copyright';
843 } else {
844 $msg = 'copyright';
845 }
846
847 $out = '';
848 if( $wgRightsPage ) {
849 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
850 } elseif( $wgRightsUrl ) {
851 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
852 } else {
853 # Give up now
854 return $out;
855 }
856 $out .= wfMsgForContent( $msg, $link );
857 return $out;
858 }
859
860 function getCopyrightIcon() {
861 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
862 $out = '';
863 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
864 $out = $wgCopyrightIcon;
865 } else if ( $wgRightsIcon ) {
866 $icon = htmlspecialchars( $wgRightsIcon );
867 if ( $wgRightsUrl ) {
868 $url = htmlspecialchars( $wgRightsUrl );
869 $out .= '<a href="'.$url.'">';
870 }
871 $text = htmlspecialchars( $wgRightsText );
872 $out .= "<img src=\"$icon\" alt='$text' />";
873 if ( $wgRightsUrl ) {
874 $out .= '</a>';
875 }
876 }
877 return $out;
878 }
879
880 function getPoweredBy() {
881 global $wgStylePath;
882 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
883 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="MediaWiki" /></a>';
884 return $img;
885 }
886
887 function lastModified() {
888 global $wgLang, $wgArticle, $wgLoadBalancer;
889
890 $timestamp = $wgArticle->getTimestamp();
891 if ( $timestamp ) {
892 $d = $wgLang->timeanddate( $timestamp, true );
893 $s = ' ' . wfMsg( 'lastmodified', $d );
894 } else {
895 $s = '';
896 }
897 if ( $wgLoadBalancer->getLaggedSlaveMode() ) {
898 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
899 }
900 return $s;
901 }
902
903 function logoText( $align = '' ) {
904 if ( '' != $align ) { $a = " align='{$align}'"; }
905 else { $a = ''; }
906
907 $mp = wfMsg( 'mainpage' );
908 $titleObj = Title::newFromText( $mp );
909 if ( is_object( $titleObj ) ) {
910 $url = $titleObj->escapeLocalURL();
911 } else {
912 $url = '';
913 }
914
915 $logourl = $this->getLogo();
916 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
917 return $s;
918 }
919
920 /**
921 * show a drop-down box of special pages
922 * @TODO crash bug913. Need to be rewrote completly.
923 */
924 function specialPagesList() {
925 global $wgUser, $wgOut, $wgContLang, $wgServer, $wgRedirectScript, $wgAvailableRights;
926 require_once('SpecialPage.php');
927 $a = array();
928 $pages = SpecialPage::getPages();
929
930 // special pages without access restriction
931 foreach ( $pages[''] as $name => $page ) {
932 $a[$name] = $page->getDescription();
933 }
934
935 // Other special pages that are restricted.
936 // Copied from SpecialSpecialpages.php
937 foreach($wgAvailableRights as $right) {
938 if( $wgUser->isAllowed($right) ) {
939 /** Add all pages for this right */
940 if(isset($pages[$right])) {
941 foreach($pages[$right] as $name => $page) {
942 $a[$name] = $page->getDescription();
943 }
944 }
945 }
946 }
947
948 $go = wfMsg( 'go' );
949 $sp = wfMsg( 'specialpages' );
950 $spp = $wgContLang->specialPage( 'Specialpages' );
951
952 $s = '<form id="specialpages" method="get" class="inline" ' .
953 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
954 $s .= "<select name=\"wpDropdown\">\n";
955 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
956
957
958 foreach ( $a as $name => $desc ) {
959 $p = $wgContLang->specialPage( $name );
960 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
961 }
962 $s .= "</select>\n";
963 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
964 $s .= "</form>\n";
965 return $s;
966 }
967
968 function mainPageLink() {
969 $mp = wfMsgForContent( 'mainpage' );
970 $mptxt = wfMsg( 'mainpage');
971 $s = $this->makeKnownLink( $mp, $mptxt );
972 return $s;
973 }
974
975 function copyrightLink() {
976 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
977 wfMsg( 'copyrightpagename' ) );
978 return $s;
979 }
980
981 function aboutLink() {
982 $s = $this->makeKnownLink( wfMsgForContent( 'aboutpage' ),
983 wfMsg( 'aboutsite' ) );
984 return $s;
985 }
986
987
988 function disclaimerLink() {
989 $disclaimers = wfMsg( 'disclaimers' );
990 if ($disclaimers == '-') {
991 return '';
992 } else {
993 return $this->makeKnownLink( wfMsgForContent( 'disclaimerpage' ),
994 $disclaimers );
995 }
996 }
997
998 function editThisPage() {
999 global $wgOut, $wgTitle, $wgRequest;
1000
1001 $oldid = $wgRequest->getVal( 'oldid' );
1002 $diff = $wgRequest->getVal( 'diff' );
1003 $redirect = $wgRequest->getVal( 'redirect' );
1004
1005 if ( ! $wgOut->isArticleRelated() ) {
1006 $s = wfMsg( 'protectedpage' );
1007 } else {
1008 if ( $wgTitle->userCanEdit() ) {
1009 $t = wfMsg( 'editthispage' );
1010 } else {
1011 $t = wfMsg( 'viewsource' );
1012 }
1013 $oid = $red = '';
1014
1015 if ( !is_null( $redirect ) ) { $red = "&redirect={$redirect}"; }
1016 if ( $oldid && ! isset( $diff ) ) {
1017 $oid = '&oldid='.$oldid;
1018 }
1019 $s = $this->makeKnownLinkObj( $wgTitle, $t, "action=edit{$oid}{$red}" );
1020 }
1021 return $s;
1022 }
1023
1024 function deleteThisPage() {
1025 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1026
1027 $diff = $wgRequest->getVal( 'diff' );
1028 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1029 $t = wfMsg( 'deletethispage' );
1030
1031 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
1032 } else {
1033 $s = '';
1034 }
1035 return $s;
1036 }
1037
1038 function protectThisPage() {
1039 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1040
1041 $diff = $wgRequest->getVal( 'diff' );
1042 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1043 if ( $wgTitle->isProtected() ) {
1044 $t = wfMsg( 'unprotectthispage' );
1045 $q = 'action=unprotect';
1046 } else {
1047 $t = wfMsg( 'protectthispage' );
1048 $q = 'action=protect';
1049 }
1050 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1051 } else {
1052 $s = '';
1053 }
1054 return $s;
1055 }
1056
1057 function watchThisPage() {
1058 global $wgUser, $wgOut, $wgTitle;
1059
1060 if ( $wgOut->isArticleRelated() ) {
1061 if ( $wgTitle->userIsWatching() ) {
1062 $t = wfMsg( 'unwatchthispage' );
1063 $q = 'action=unwatch';
1064 } else {
1065 $t = wfMsg( 'watchthispage' );
1066 $q = 'action=watch';
1067 }
1068 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1069 } else {
1070 $s = wfMsg( 'notanarticle' );
1071 }
1072 return $s;
1073 }
1074
1075 function moveThisPage() {
1076 global $wgTitle;
1077
1078 if ( $wgTitle->userCanMove() ) {
1079 return $this->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, 'Movepage' ),
1080 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1081 } else {
1082 // no message if page is protected - would be redundant
1083 return '';
1084 }
1085 }
1086
1087 function historyLink() {
1088 global $wgTitle;
1089
1090 return $this->makeKnownLinkObj( $wgTitle,
1091 wfMsg( 'history' ), 'action=history' );
1092 }
1093
1094 function whatLinksHere() {
1095 global $wgTitle;
1096
1097 return $this->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, 'Whatlinkshere' ),
1098 wfMsg( 'whatlinkshere' ), 'target=' . $wgTitle->getPrefixedURL() );
1099 }
1100
1101 function userContribsLink() {
1102 global $wgTitle;
1103
1104 return $this->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, 'Contributions' ),
1105 wfMsg( 'contributions' ), 'target=' . $wgTitle->getPartialURL() );
1106 }
1107
1108 function showEmailUser( $id ) {
1109 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1110 return $wgEnableEmail &&
1111 $wgEnableUserEmail &&
1112 $wgUser->isLoggedIn() && # show only to signed in users
1113 0 != $id; # we can only email to non-anons ..
1114 # '' != $id->getEmail() && # who must have an email address stored ..
1115 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1116 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1117 }
1118
1119 function emailUserLink() {
1120 global $wgTitle;
1121
1122 return $this->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, 'Emailuser' ),
1123 wfMsg( 'emailuser' ), 'target=' . $wgTitle->getPartialURL() );
1124 }
1125
1126 function watchPageLinksLink() {
1127 global $wgOut, $wgTitle;
1128
1129 if ( ! $wgOut->isArticleRelated() ) {
1130 return '(' . wfMsg( 'notanarticle' ) . ')';
1131 } else {
1132 return $this->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL,
1133 'Recentchangeslinked' ), wfMsg( 'recentchangeslinked' ),
1134 'target=' . $wgTitle->getPrefixedURL() );
1135 }
1136 }
1137
1138 function trackbackLink() {
1139 global $wgTitle;
1140
1141 return "<a href=\"" . $wgTitle->trackbackURL() . "\">"
1142 . wfMsg('trackbacklink') . "</a>";
1143 }
1144
1145 function otherLanguages() {
1146 global $wgOut, $wgContLang, $wgTitle, $wgHideInterlanguageLinks;
1147
1148 if ( $wgHideInterlanguageLinks ) {
1149 return '';
1150 }
1151
1152 $a = $wgOut->getLanguageLinks();
1153 if ( 0 == count( $a ) ) {
1154 return '';
1155 }
1156
1157 $s = wfMsg( 'otherlanguages' ) . ': ';
1158 $first = true;
1159 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1160 foreach( $a as $l ) {
1161 if ( ! $first ) { $s .= ' | '; }
1162 $first = false;
1163
1164 $nt = Title::newFromText( $l );
1165 $url = $nt->escapeFullURL();
1166 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1167
1168 if ( '' == $text ) { $text = $l; }
1169 $style = $this->getExternalLinkAttributes( $l, $text );
1170 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1171 }
1172 if($wgContLang->isRTL()) $s .= '</span>';
1173 return $s;
1174 }
1175
1176 function bugReportsLink() {
1177 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1178 wfMsg( 'bugreports' ) );
1179 return $s;
1180 }
1181
1182 function dateLink() {
1183 global $wgLinkCache;
1184 $t1 = Title::newFromText( gmdate( 'F j' ) );
1185 $t2 = Title::newFromText( gmdate( 'Y' ) );
1186
1187 $wgLinkCache->suspend();
1188 $id = $t1->getArticleID();
1189 $wgLinkCache->resume();
1190
1191 if ( 0 == $id ) {
1192 $s = $this->makeBrokenLink( $t1->getText() );
1193 } else {
1194 $s = $this->makeKnownLink( $t1->getText() );
1195 }
1196 $s .= ', ';
1197
1198 $wgLinkCache->suspend();
1199 $id = $t2->getArticleID();
1200 $wgLinkCache->resume();
1201
1202 if ( 0 == $id ) {
1203 $s .= $this->makeBrokenLink( $t2->getText() );
1204 } else {
1205 $s .= $this->makeKnownLink( $t2->getText() );
1206 }
1207 return $s;
1208 }
1209
1210 function talkLink() {
1211 global $wgTitle, $wgLinkCache;
1212
1213 if ( NS_SPECIAL == $wgTitle->getNamespace() ) {
1214 # No discussion links for special pages
1215 return '';
1216 }
1217
1218 if( $wgTitle->isTalkPage() ) {
1219 $link = $wgTitle->getSubjectPage();
1220 switch( $link->getNamespace() ) {
1221 case NS_MAIN:
1222 $text = wfMsg('articlepage');
1223 break;
1224 case NS_USER:
1225 $text = wfMsg('userpage');
1226 break;
1227 case NS_PROJECT:
1228 $text = wfMsg('wikipediapage');
1229 break;
1230 case NS_IMAGE:
1231 $text = wfMsg('imagepage');
1232 break;
1233 default:
1234 $text= wfMsg('articlepage');
1235 }
1236 } else {
1237 $link = $wgTitle->getTalkPage();
1238 $text = wfMsg( 'talkpage' );
1239 }
1240
1241 $wgLinkCache->suspend();
1242 $s = $this->makeLinkObj( $link, $text );
1243 $wgLinkCache->resume();
1244
1245 return $s;
1246 }
1247
1248 function commentLink() {
1249 global $wgContLang, $wgTitle, $wgLinkCache;
1250
1251 if ( $wgTitle->getNamespace() == NS_SPECIAL ) {
1252 return '';
1253 }
1254 return $this->makeKnownLinkObj( $wgTitle->getTalkPage(),
1255 wfMsg( 'postcomment' ), 'action=edit&section=new' );
1256 }
1257
1258 /* these are used extensively in SkinPHPTal, but also some other places */
1259 /*static*/ function makeSpecialUrl( $name, $urlaction='' ) {
1260 $title = Title::makeTitle( NS_SPECIAL, $name );
1261 return $title->getLocalURL( $urlaction );
1262 }
1263
1264 /*static*/ function makeI18nUrl ( $name, $urlaction='' ) {
1265 $title = Title::newFromText( wfMsgForContent($name) );
1266 $this->checkTitle($title, $name);
1267 return $title->getLocalURL( $urlaction );
1268 }
1269
1270 /*static*/ function makeUrl ( $name, $urlaction='' ) {
1271 $title = Title::newFromText( $name );
1272 $this->checkTitle($title, $name);
1273 return $title->getLocalURL( $urlaction );
1274 }
1275
1276 # If url string starts with http, consider as external URL, else
1277 # internal
1278 /*static*/ function makeInternalOrExternalUrl( $name ) {
1279 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
1280 return $name;
1281 } else {
1282 return $this->makeUrl( $name );
1283 }
1284 }
1285
1286 # this can be passed the NS number as defined in Language.php
1287 /*static*/ function makeNSUrl( $name, $urlaction='', $namespace=NS_MAIN ) {
1288 $title = Title::makeTitleSafe( $namespace, $name );
1289 $this->checkTitle($title, $name);
1290 return $title->getLocalURL( $urlaction );
1291 }
1292
1293 /* these return an array with the 'href' and boolean 'exists' */
1294 /*static*/ function makeUrlDetails ( $name, $urlaction='' ) {
1295 $title = Title::newFromText( $name );
1296 $this->checkTitle($title, $name);
1297 return array(
1298 'href' => $title->getLocalURL( $urlaction ),
1299 'exists' => $title->getArticleID() != 0?true:false
1300 );
1301 }
1302
1303 /**
1304 * Make URL details where the article exists (or at least it's convenient to think so)
1305 */
1306 function makeKnownUrlDetails( $name, $urlaction='' ) {
1307 $title = Title::newFromText( $name );
1308 $this->checkTitle($title, $name);
1309 return array(
1310 'href' => $title->getLocalURL( $urlaction ),
1311 'exists' => true
1312 );
1313 }
1314
1315 # make sure we have some title to operate on
1316 /*static*/ function checkTitle ( &$title, &$name ) {
1317 if(!is_object($title)) {
1318 $title = Title::newFromText( $name );
1319 if(!is_object($title)) {
1320 $title = Title::newFromText( '--error: link target missing--' );
1321 }
1322 }
1323 }
1324
1325 /**
1326 * Build an array that represents the sidebar(s), the navigation bar among them
1327 *
1328 * @return array
1329 * @access private
1330 */
1331 function buildSidebar() {
1332 global $wgTitle, $action;
1333
1334 $fname = 'SkinTemplate::buildSidebar';
1335 $pageurl = $wgTitle->getLocalURL();
1336 wfProfileIn( $fname );
1337
1338 $bar = array();
1339 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
1340 foreach ($lines as $line) {
1341 if (strpos($line, '*') !== 0)
1342 continue;
1343 if (strpos($line, '**') !== 0) {
1344 $line = trim($line, '* ');
1345 $heading = $line;
1346 } else {
1347 if (strpos($line, '|') !== false) { // sanity check
1348 $line = explode( '|' , trim($line, '* '), 2 );
1349 $link = wfMsgForContent( $line[0] );
1350 if ($link == '-')
1351 continue;
1352 if (wfEmptyMsg($line[1], $text = wfMsg($line[1])))
1353 $text = $line[1];
1354 if (wfEmptyMsg($line[0], $link))
1355 $link = $line[0];
1356 $href = $this->makeInternalOrExternalUrl( $link );
1357 $bar[$heading][] = array(
1358 'text' => $text,
1359 'href' => $href,
1360 'id' => 'n-' . strtr($line[1], ' ', '-'),
1361 'active' => $pageurl == $href
1362 );
1363 } else { continue; }
1364 }
1365 }
1366
1367 wfProfileOut( $fname );
1368 return $bar;
1369 }
1370 }
1371
1372 }
1373 ?>